<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="task_group_context">
<meta name="DC.subject" content="task_group_context">
<meta name="keywords" content="task_group_context">
<meta name="DC.Relation" scheme="URI" content="../../reference/task_scheduler.htm">
<meta name="DC.Relation" scheme="URI" content="../../reference/task_scheduler/task_group_context/task_group_context.htm">
<meta name="DC.Relation" scheme="URI" content="priorities.htm">
<meta name="DC.Relation" scheme="URI" content="task_scheduler_init_cls/task_scheduler_init_1.htm">
<meta name="DC.Relation" scheme="URI" content="task_context.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="task_group_context">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../intel_css_styles.css">
<title>task_group_context</title>
</head>
<body id="task_group_context">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(2);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="task_group_context"><!-- --></a>

 
  <h1 class="topictitle1">task_group_context</h1>
 
   
  <div> 
	 <div class="section"><h2 class="sectiontitle">Summary</h2> 
		 
		<p>A cancellable group of tasks. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Syntax</h2> 
		 
		<pre>class task_group_context;</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Header</h2> 
		 
		<pre>#include "tbb/task.h"</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Description</h2> 
		 
		<p>A 
		  <samp class="codeph">task_group_context</samp> represents a group of tasks that
		  can be cancelled, or have their priority level set, together. All tasks belong
		  to some group. A task can be a member of only one group at any moment. 
		</p>
 
		<p>A root task is associated with a group by passing 
		  <samp class="codeph">task_group_context 
		  </samp>object into<samp class="codeph"> task::allocate_root()</samp> call. A
		  child task automatically joins its parent task's group. A task can be moved
		  into other group using 
		  <samp class="codeph">task::change_group() 
		  </samp>method. 
		</p>
 
		<p>The 
		  <samp class="codeph">task_group_context</samp> objects form a forest of trees.
		  Each tree's root is a 
		  <samp class="codeph">task_group_context</samp> constructed as 
		  <samp class="codeph">isolated</samp>. 
		</p>
 
		<p>A 
		  <samp class="codeph">task_group_context</samp> is cancelled explicitly by request,
		  or implicitly when an exception is thrown out of a task. Canceling a 
		  <samp class="codeph">task_group_context</samp> causes the entire subtree rooted at
		  it to be cancelled. 
		</p>
 
		<p>The priorities for all the tasks in a group can be
		  changed at any time either via the associated 
		  <samp class="codeph">task_group_context</samp> object, or via any task belonging
		  to the group. Priority changes propagate into the child task groups similarly
		  to cancellation. The effect of priorities on task execution is described in
		  Section Priorities. 
		</p>
 
		<p>Each user thread that creates a 
		  <samp class="codeph">task_scheduler_init</samp> implicitly has an 
		  <samp class="codeph">isolated task_group_context</samp> that acts as the root of
		  its initial tree. This context is associated with the dummy task returned by 
		  <samp class="codeph">task::self()</samp> when the user thread is not running any
		  task. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Members</h2> 
		 
		<pre> namespace tbb {
     &nbsp;  class task_group_context {
        public:
            enum kind_t {
                isolated = implementation-defined,
                bound = implementation-defined
            };

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum traits_type {
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exact_exception = implementation-defined,
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; concurrent_wait = implementation-defined,
    #if TBB_USE_CAPTURED_EXCEPTION
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default_traits = 0
    #else
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  default_traits = exact_exception
    #endif /* !TBB_USE_CAPTURED_EXCEPTION */
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task_group_context( kind_t relation_with_parent = bound, 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uintptr_t traits = default_traits );
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~task_group_context();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void reset();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool cancel_group_execution();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool is_group_execution_cancelled() const;
            void set_priority ( priority_t );
            priority_t priority () const;
    &nbsp;&nbsp;&nbsp; };&nbsp; 
    }</pre> 
	 </div>
 
	 
<div class="tablenoborder"><table cellpadding="4" summary="" frame="border" border="1" cellspacing="0" rules="all"><span class="tabledesc">The following table provides additional information on the members
		  of this template class. 
		</span><thead align="left"> 
			 <tr> 
				<th class="cellrowborder" valign="top" width="33.89830508474576%" id="d114825e130">Member 
				</th>
 
				<th class="cellrowborder" valign="top" width="66.10169491525423%" id="d114825e133">Description 
				</th>
 
			 </tr>
</thead>
 
		  <tbody> 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">task_group_context( kind_t
					 relation_to_parent=bound, uintptr_t traits=default_traits )</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p>Constructs an empty 
					 <samp class="codeph">task_group_context</samp>. If 
					 <em>relation_to_parent</em> is bound, the 
					 <samp class="codeph">task_group_context</samp> will become a child of the
					 innermost running task's group when it is first passed into the call to 
					 <samp class="codeph">task::allocate_root(task_group_context&amp;)</samp>.
					 If this call is made directly from the user thread, the effect will be as if 
					 <samp class="codeph"><em>relation_to_parent</em></samp> were isolated. If 
					 <samp class="codeph"><em>relation_to_parent</em></samp> is 
					 <em>isolated</em>, it has no parent 
					 <samp class="codeph">task_group_context</samp>. 
				  </p>
 
				  <p>The 
					 <em>traits</em> argument should be the bitwise OR of 
					 <em>traits_type</em> values. The flag 
					 <samp class="codeph">exact_exception</samp> controls how precisely
					 exceptions are transferred between threads. See Section Exceptions for details.
					 The flag 
					 <samp class="codeph">concurrent_wait</samp> controls the
					 reference-counting behavior of methods 
					 <samp class="codeph">task::wait_for_all</samp> and 
					 <samp class="codeph">task::spawn_and_wait_for_all</samp>. 
				  </p>
 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">~task_group_context()</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p>Destroys an empty task_group_context. It is
					 a programmer error if there are still extant tasks in the group. 
				  </p>
 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword"> bool
					 cancel_group_execution()</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p>Requests that tasks in group be cancelled. 
				  </p>
 
				  <p><strong>Returns</strong>: False if group is already
					 cancelled; true otherwise. If concurrently called by multiple threads, exactly
					 one call returns true and the rest return false. 
				  </p>
 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">bool is_group_execution_cancelled()
					 const</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p><strong>Returns</strong>: True if group has received
					 cancellation. 
				  </p>
 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">void reset()</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p>Reinitializes this to uncancelled state. 
				  </p>
 
				  <div class="Note"><h3 class="NoteTipHead">
					Caution</h3> 
					 <p>This method is only safe to call once all tasks associated
						with the group's subordinate groups have completed. This method must not be
						invoked concurrently by multiple threads. 
					 </p>
 
				  </div> 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">void set_priority ( priority_t
					 )</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p>Changes priority of the task group. 
				  </p>
 
				</td>
 
			 </tr>
 
			 <tr> 
				<td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d114825e130 "><span class="keyword">priority_t priority ()
					 const</span> 
				</td>
 
				<td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d114825e133 "> 
				  <p><strong>Returns</strong>: Priority of the task group.
					 
				  </p>
 
				</td>
 
			 </tr>
 
		  </tbody>
 
		</table>
</div>

  </div>
 
  
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../../reference/task_scheduler.htm">Task Scheduler</a></div>
</div>
<div class="See Also">
<ul class="ullinks">
<li class="ulchildlink"><a href="../../reference/task_scheduler/task_group_context/task_group_context.htm">task_group_context Members</a><br>
</li>
</ul>

<h2>See Also</h2>
<div class="linklist">
<div><a href="priorities.htm">Priorities 
		  </a></div>
<div><a href="task_scheduler_init_cls/task_scheduler_init_1.htm">task_scheduler_init 
		  </a></div>
<div><a href="task_context.htm">Task Context, static task&amp; self() 
		  </a></div></div>
</div>

</body>
</html>
